package cjq.demo.instrument;

import java.lang.instrument.ClassFileTransformer;
import java.lang.instrument.IllegalClassFormatException;
import java.lang.instrument.Instrumentation;
import java.security.ProtectionDomain;

/**
 * Created by cjq on 2016/3/17.
 */
public class MyClassFileTransformer implements ClassFileTransformer {
    @Override
    public byte[] transform(ClassLoader loader,
                            String className,
                            Class<?> classBeingRedefined,
                            ProtectionDomain protectionDomain,
                            byte[] classfileBuffer) throws IllegalClassFormatException {
        System.out.println("MyClassFileTransformer.transform");
        return new byte[0];
    }

    public static void premain(String args,Instrumentation inst){
        inst.addTransformer(new MyClassFileTransformer());
    }

    public static void main(String args[]){
        System.out.println("main...");
    }
}
